﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    


<head>
	<script type="text/javascript">
		$(function(){
			$('#topmenu-hotkeyword').addClass('e-topmenu-selected');
				init();
		});
		
			function init(){
				$('#t-dg').datagrid({
				loadMsg:''
				
			});
				
			}

		function formatstatus(value,row){
   if (row.status == 1){
      return "生效";
   } else {
      return "暂不生效";
   }
}

		

		var actionUrl;
		function newItem(){
			$('#dlg').dialog('setTitle', '新增查询').dialog('open');
			$('#myform').form('clear');
			actionUrl = '<c:url value="/portal/Hotkeyword/saveHotkeyword"/>';
		}
		function editItem(){
			var t = $('#t-dg');
			var row = t.datagrid('getSelected');
			if (row){
				$('#myform').form('load', row);
				$('#dlg').dialog('setTitle', '修改查询').dialog('open');
				actionUrl = '<c:url value="/portal/Hotkeyword/updateHotkeyword"/>?id=' + row.id;
			}
		}
		
		function deleteItem(){
			var t = $('#t-dg');
			var row = t.datagrid('getSelected');
			if (row){
				
				$.messager.confirm('删除确认', '是否确定要删除选择查询配置?', function(r){
						if (r){
				$.ajax({
					url:'<c:url value="/portal/Hotkeyword/destroyHotkeyword"/>?id=' + row.id,
					type:'post',
					success:function(){
						$('#t-dg').datagrid('reload');
					}
				});
			}});
				
			}
		}
		
		function saveItem(){
			$('#myform').form('submit', {
				url:actionUrl,
				onSubmit:function(){
					return $('#myform').form('validate');
				},
				success:function(data){
					var data = eval('('+data+')');
					if (data.success){
						$('#dlg').dialog('close');
						$('#t-dg').datagrid('reload');
					} else {
						$.messager.show({
							title:'保存失败',
							msg:'<pre>'+data.msg+'</pre>'
						});
					}
				}
			});
		}
		function doQuery(value){
			$('#t-dg').datagrid('load', {
				q: value
			});
		}
	</script>
</head>
<body>
	<div class="easyui-layout" fit="true">
		<div region="north" border="false" style="height:40px;padding:5px;overflow:hidden;">
			<div style="padding-top:3px;float:left">
			<input class="easyui-searchbox" prompt="按描述|条件进行查询" searcher="doQuery" style="width:300px"></input>
		</div>
		<div style="float:left">
			<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newItem()">新增查询</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editItem()">修改查询</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteItem()">删除查询</a>			
		</div>
	</div>
		
		
		<div region="center" border="false">
			<table id="t-dg" style="display:none;"
					url="<c:url value='/portal/Hotkeyword/getHotkeywordItems'/>"
					singleSelect="true" rownumbers="true" pagination="true"
					border="false" fit="true" fitColumns="true">
				<thead>
					<tr>
					<th field="code" width="100" sortable="true">代号</th>
						<th field="word" width="100" sortable="true">描述</th>
<th field="cond" width="100" sortable="false">查询条件</th>
<th field="sort" width="100" sortable="true">排序</th>
<th field="groupid" width="100" sortable="true">分组号</th>
<th field="status" width="100" sortable="true" formatter="formatstatus">状态</th>

					</tr>
				</thead>
			</table>
		</div>
	</div>
	
<div id="dlg" style="width:400px;height:250px;"
			class="easyui-dialog" closed="true" modal="true" buttons="#dlg-buttons">
		<div style="padding:10px">
			<div style="float:left">
				<form id="myform" method="post" style="margin:0;padding:0">
					<table>
<tr>
<td style="width:80px">代号</td>
<td><input type="text" class="easyui-validatebox e-input" id="code" name="code" style="width:250px;" data-options="required:true,editable:true" ></input></td>
</tr>						
						<tr>
<td style="width:80px">描述</td>
<td><input type="text" class="easyui-validatebox e-input" id="word" name="word" style="width:250px;" data-options="required:true,editable:true" ></input></td>
</tr>	
<tr>
<td style="width:80px">查询条件</td>
<td><input type="text" class="easyui-validatebox e-input" id="cond" name="cond" style="width:250px;" data-options="required:true,editable:true" ></input></td>
</tr>	
<tr>
<td style="width:80px">排序</td>
<td><input type="text" class="easyui-numberbox" precision="0" id="sort" name="sort" style="width:250px;" data-options="required:true,editable:true" ></input></td>
</tr>	
<tr>
<td style="width:80px">分组号</td>
<td>
	<input type="text" class="easyui-numberspinner" increment="1" min="1" max="10000"  id="groupid" name="groupid" style="width:250px;" data-options="required:false,editable:true" ></input>
	</td>
</tr>	
<tr>
<td style="width:80px">状态</td>
<td>
<select id="status" name="status" 
	data-options="required:false,editable:false" panelHeight="auto" class="easyui-combobox" style="width:250px;">
		<option value="0">暂不生效</option>	
		<option value="1">生效</option>		
</select></td>
</tr>	


								
					</table>
				</form>
			</div>			
			<div style="clear:both"></div>
		</div>
		<div id="dlg-buttons" style="text-align:center;">
			<a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="saveItem()">保存</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
		</div>
</div>

	

</body>
